<template>
  <div class="sex-container">
    <div class="title">
      <p>男女比例</p>
      <img src="../images/dataScreen-title.png" alt="" />
    </div>
    <div class="sex">
      <div class="man">
        <img src="../images/man.png" alt="" />
      </div>
      <div class="woman">
        <img src="../images/woman.png" alt="" />
      </div>
    </div>
    <div class="rate">
      <p>男士：58%</p>
      <p>女士：42%</p>
    </div>

    <div class="chart-container" ref="chartContainer"></div>
  </div>
</template>

<script setup lang="ts">
import * as echarts from 'echarts'
import { onMounted, ref } from 'vue'
let chartContainer = ref()
const option = {
  xAxis: {
    min: 0,
    max: 100,
    show: false,
  },
  yAxis: {
    show: false,
    type: 'category',
  },
  series: [
    {
      type: 'bar',
      data: [58],
      barWidth: 20,
      z: 10,
      itemStyle: {
        color: 'skyblue',
        borderRadius: 15,
      },
    },
    {
      type: 'bar',
      barWidth: 20,
      barGap: '-100%',
      itemStyle: {
        color: 'pink',
        borderRadius: 15,
      },
      data: [100],
    },
  ],

  grid: {
    top: 0,
    left: 0,
    bottom: 0,
    right: 0,
  },
}
onMounted(() => {
  let myChart = echarts.init(chartContainer.value)
  myChart.setOption(option)
})
</script>

<style lang="scss" scoped>
.sex-container {
  width: 100%;
  height: 100%;
  background: url('../images/dataScreen-main-cb.png') no-repeat;
  background-size: 100% 100%;
  .title {
    padding-left: 20px;
    p {
      color: #fff;
    }
  }
  .sex {
    margin-top: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    > div {
      width: 111px;
      height: 115px;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .man {
      background: url('../images/man-bg.png') no-repeat;
    }
    .woman {
      background: url('../images/woman-bg.png') no-repeat;
    }
  }
  .rate {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    color: #fff;
  }
  .chart-container {
    width: 100%;
    height: 100px;
  }
}
</style>
